<template>
  <div>
    <Form :model="formItem">
<!--      <h3>户主个人信息</h3>-->
      <div class="title-style">户主个人信息</div>
<!--      <Divider style="margin: 5px;" />-->
      <Row :gutter="24">
        <Col span="8">
          <FormItem label="姓名">
            <Input disabled v-model="formItem.person_name"></Input>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="身份证号">
            <Input disabled v-model="formItem.person_card_no"></Input>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="性别">
            <Input disabled v-model="formItem.person_sex"></Input>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="24">
        <Col span="8">
          <FormItem label="救助类型">
            <Select disabled v-model="formItem.subsidy_type">
              <Option :value="'110'">农村低保</Option>
              <Option :value="'120'">城市低保</Option>
              <Option :value="'140'">特困人员供养（农村）</Option>
              <Option :value="'150'">特困人员供养（城市）</Option>
              <Option :value="'610'">低保边缘家庭（城市）</Option>
              <Option :value="'620'">低保边缘家庭（农村）</Option>
              <Option :value="''">非保障人员</Option>
            </Select>
<!--            <Input v-model="formItem.subsidy_type"></Input>-->
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="救助证件号码">
            <Input disabled v-model="formItem.subsidy_no"></Input>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="详细地址">
            <Input disabled v-model="formItem.address"></Input>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="24">
        <Col span="8">
          <FormItem label="开始居住时间">
            <Input disabled v-model="formItem.start_in_time"></Input>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="联系电话(宅电)">
            <Input disabled v-model="formItem.tel"></Input>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="联系电话(手机)">
            <Input disabled v-model="formItem.mobile"></Input>
          </FormItem>
        </Col>
      </Row>
<!--      <Divider style="margin: 10px 0" />-->
<!--      <h3>救助补贴</h3>-->
      <div class="title-style">救助补贴</div>
<!--      <Divider style="margin: 5px;"/>-->
      <Row :gutter="24">
        <Col span="24">
          <FormItem prop="gender">
            <template #label>
              <span style="color: red">*</span><span>采暖方式：</span>
            </template>
            <RadioGroup v-if="cnTypeState" v-model="formItem.cn_type" @on-change="updateCnType">
              <Radio :disabled="formItem.operation === '2'" :label="'1'">集中采暖</Radio >
              <Radio :disabled="formItem.operation === '2'" :label="'2'">分散采暖</Radio >
             <Radio :disabled="formItem.operation === '2'" :label="'3'">集中采暖（借住采暖）</Radio >
            </RadioGroup >
          </FormItem>
        </Col>
      </Row>
      <concentrated :paramsData="formItem" ref="concentrated" v-if="formItem.cn_type !== '' && formItem.cn_type === '1'"></concentrated> <!--集中采暖-->
      <dispersion :paramsData="formItem" ref="dispersion" v-if="formItem.cn_type !== '' && formItem.cn_type === '2'"></dispersion><!--分散采暖-->
      <borrow @init="init" :paramsData="formItem" ref="borrow" v-if="formItem.cn_type !== '' && formItem.cn_type === '3'"></borrow>
      <family @familyLenght="familyLenght" ref="family" :paramsData="formItem" :data="familyList" v-if="formItem.cn_type !== undefined && formItem.cn_type !== ''"></family> <!--成员信息-->
      <ConcentratedAppendix :paramsData="formItem" ref="concentratedAppendix" v-if="formItem.cn_type !== '' && formItem.cn_type === '1'"></ConcentratedAppendix> <!--集中采暖上传附件-->
      <DispersionAppendix :paramsData="formItem" ref="dispersionAppendix" v-if="formItem.cn_type !== '' && formItem.cn_type === '2'"></DispersionAppendix>
      <BorrowAppendix :paramsData="formItem" ref="borrowAppendix" v-if="formItem.cn_type !== '' && formItem.cn_type === '3' && borrowAppendixType"></BorrowAppendix>
    </Form>
    <Checkbox v-if="formItem.cn_type === '1'" v-model="formItem.single">我已进行核对申报者“四证统一”信息（身份证、户口本、房产证、《辽宁省城市（农村）居民最低生活保障证》、《特困人员救助供养证》或《辽宁省城市（农村）低收入家庭救助证》）信息均准确无误。</Checkbox>
    <Checkbox v-if="formItem.cn_type === '2'" v-model="formItem.single">我已核对申报者为分散供暖人员，同时符合采暖申报补贴标准，已核对分散供暖证明及常住人口证明，已明确补贴标准规则并确认无误。</Checkbox>
    <Checkbox v-if="formItem.cn_type === '3'" v-model="formItem.single">申报者符合采暖申报补贴标准，且已承诺无自有住房并未享受租赁补贴，已核对同住人员单位信息与单位不报销证明，已明确补贴标准规则并确认无误</Checkbox>
    <div style="text-align: right">
      <Button :disabled="!formItem.single" v-if="formItem.operation === '' || formItem.operation === undefined" style="margin-right: 10px" size="large" type="success" @click="ok">保存</Button>
      <Button :disabled="!formItem.single" v-if="formItem.operation === '1'" size="large" type="success" style="margin-right: 10px" @click="updateInfo">保存</Button>
<!--      <Button size="large" type="success" @click="goBack">返回</Button>-->
    </div>
  </div>
</template>
<script>
import concentrated from './components/concentrated'
import family from './components/family'
import ConcentratedAppendix from './components/concentrated-appendix'
import dispersion from './components/dispersion'
import DispersionAppendix from './components/dispersion-appendix'
import borrow from './components/borrow'
import BorrowAppendix from './components/borrow-appendix'
import { postCN, updateOrder, createOrder } from '@/api/eventlist'
export default {
  components: { concentrated, family, ConcentratedAppendix, dispersion, DispersionAppendix, borrow, BorrowAppendix },
  data () {
    return {
      cn_type: '',
      single: false,
      cnTypeState: true,
      formItem: {
        cn_type: '',
        person_name: '',
        person_card_no: '',
        settingList: [],
        single: false
      },
      baseInfo: {
        area: '',
        street: '',
        community: '',
        area_code: ''
      },
      borrowAppendixType: true,
      type: this.$route.params.type,
      familyList: [],
      arrayData: {}
    }
  },
  methods: {
    ok () {
      let formItem = {}
      let familyList = this.$refs.family.dataList
      if (this.formItem.cn_type === '1') { // 集中供暖
        // console.log(this.$refs.concentrated.formItem)
        formItem = this.$refs.concentrated.formItem
        formItem.params = this.$refs.concentratedAppendix.params
        let a_address = formItem.a_address
        let d_address = formItem.d_address
        d_address = d_address.replace(' ', '')
        if (a_address !== d_address) {
          let msg = '原始登记地址和填写地址不同，是否继续'
          if (!confirm(msg)) {
            return
          }
        }
        // if (!formItem.params.房产证) {
        //   this.$Notice.error({
        //     title: '房产证图片不能为空',
        //     desc: ''
        //   })
        //   return
        // }
        if (!formItem.work_address) {
          this.$Notice.error({
            title: '工作单位不能为空',
            desc: ''
          })
          return
        }
        if (formItem.subsidy_rmbone === 0) {
          this.$Notice.error({
            title: '采暖报销单价应大于0',
            desc: ''
          })
          return
        }
        // if (!formItem.fc_no) {
        //   this.$Notice.error({
        //     title: '房产证号不能为空',
        //     desc: ''
        //   })
        //   return
        // }
        if (!formItem.fc_m2) {
          this.$Notice.error({
            title: '房屋建筑面积不能为空',
            desc: ''
          })
          return
        }
      } else if (this.formItem.cn_type === '2') { // 分散供暖
        formItem = this.$refs.dispersion.formItem
        formItem.params = this.$refs.dispersionAppendix.params
        if (!formItem.work_address) {
          this.$Notice.error({
            title: '工作单位不能为空',
            desc: ''
          })
          return
        }
        if (!formItem.zf_type) {
          this.$Notice.error({
            title: '住房性质不能为空',
            desc: ''
          })
          return
        }
        if (!formItem.jz_type) {
          this.$Notice.error({
            title: '居住楼房/平房不能为空',
            desc: ''
          })
          return
        }
        if (!formItem.subsidy_mode) {
          this.$Notice.error({
            title: '补贴标准不能为空',
            desc: ''
          })
          return
        }
        // if (!formItem.params.常住人口证明) {
        //   this.$Notice.error({
        //     title: '常住人口证明图片不能为空',
        //     desc: ''
        //   })
        //   return
        // }
      } else if (this.formItem.cn_type === '3') { // 借住采暖
        // console.log(this.$refs.borrow.formItem)
        formItem = this.$refs.borrow.formItem
        let HeatingImgList = this.$refs.borrowAppendix.HeatingImgList
        formItem.params = this.$refs.borrowAppendix.params
        if (!formItem.fc_m2) {
          this.$Notice.error({
            title: '房屋建筑面积不能为空',
            desc: ''
          })
          return
        }
        if (formItem.subsidy_rmbone === 0) {
          this.$Notice.error({
            title: '采暖报销单价应大于0',
            desc: ''
          })
          return
        }
        // if (!formItem.fc_no) {
        //   this.$Notice.error({
        //     title: '房产证号不能为空',
        //     desc: ''
        //   })
        //   return
        // }
        // if (formItem.jz_mode === '租赁房屋') {
        //   if (!formItem.params.房屋租赁合同) {
        //     this.$Notice.error({
        //       title: '房屋租赁合同图片不能为空',
        //       desc: ''
        //     })
        //     return
        //   }
        //   if (!formItem.params.租房未补贴证明) {
        //     this.$Notice.error({
        //       title: '租房未补贴证明图片不能为空',
        //       desc: ''
        //     })
        //     return
        //   }
        // }
        let index = 0
        familyList.forEach(function (item) {
          if (item.is_subsidy === '0') {
            index += 1
          }
        })
        // if (formItem.jz_mode === '借住房屋') {
        //   if (!formItem.params.房产证) {
        //     this.$Notice.error({
        //       title: '房产证图片不能为空',
        //       desc: ''
        //     })
        //     return
        //   }
        //   if (!formItem.params.采暖不报销证明 && index > 0) {
        //     this.$Notice.error({
        //       title: '采暖不报销证明图片不能为空',
        //       desc: ''
        //     })
        //     return
        //   }
        // }
        // console.log(HeatingImgList.length, 'length')
        if (HeatingImgList.length !== index) {
          let msg = '采暖不报销证明与家庭非保障成员数量不一致,是否提交'
          if (!confirm(msg)) {
            return
          }
        }
      }
      if (!formItem.city || !formItem.street || !formItem.community) {
        this.$Notice.error({
          title: '家庭地址不能为空',
          desc: ''
        })
        return
      }
      if (!formItem.address) {
        this.$Notice.error({
          title: '详细地址不能为空',
          desc: ''
        })
        return
      }
      let data = {
        item_id: this.$route.params.itemid,
        cardno: this.$route.params.cardno,
        name: this.formItem.person_name,
        mobile: this.formItem.mobile
      }
      createOrder(data).then(res => {
        if (res.data.errcode === 0) {
          // JSON.stringify(param.form_params)
          let subsidy_type = ''
          if (this.formItem.cn_type === '1' || this.formItem.cn_type === '3') {
            subsidy_type = '1'
          } else if (this.formItem.cn_type === '2') {
            subsidy_type = '2'
          }
          let area = JSON.parse(formItem.city)
          let street = JSON.parse(formItem.street)
          let community = JSON.parse(formItem.community)
          let params = {
            orderMap: {
              sex: this.formItem.person_sex,
              name: this.formItem.person_name,
              card_no: data.cardno, // 身份证号
              user_type: this.formItem.subsidy_type, // 救助类型
              single: this.formItem.single,
              type: this.type
            },
            infoMap: {
              fc_no: formItem.fc_no,
              work_address: formItem.work_address,
              area_code: community.area_code, // 行政区划码
              cn_type: this.formItem.cn_type, // 采暖方式1集中采暖2分散采暖3集中采暖（借住采暖）
              subsidy_type: subsidy_type, // 救助方式1 集中供暖 2 自行取暖
              params: formItem.params, // 要件
              fc_m2: formItem.fc_m2, // 房屋建筑面积
              subsidy_m2up: formItem.subsidy_m2up, // 补贴上限面积
              subsidy_rmb: formItem.subsidy_rmb, // 补贴金额
              persion_rmb: formItem.persion_rmb, // 个人承担金额
              subsidy_rmbone: formItem.subsidy_rmbone, // 采暖报销单价
              subsidy_mode: formItem.subsidy_mode, // 采暖补贴标准
              zf_type: formItem.zf_type, // 住房性质
              jz_type: formItem.jz_type, // 居住楼房平房
              jz_mode: formItem.jz_mode, // 居住方式
              area: area.name, // 所在区县
              street: street.name, // 所在街道
              community: community.name, // 所在社区
              remark: formItem.cn_rmb_all,
              address: formItem.d_address
            },
            homeMap: {
              person_name: this.formItem.person_name, // 户主姓名
              person_card_no: this.formItem.person_card_no, // 户主证件
              person_sex: this.formItem.person_sex, // 性别
              subsidy_type: this.formItem.subsidy_type, // 保障类型
              subsidy_no: this.formItem.subsidy_no, // 救助证号
              mobile: this.formItem.mobile, // 联系方式
              insert_type: '系统获取', // 添加方式 ：系统获取 、 手动添加
              insert_name: this.companyName, // 添加人
              address: this.formItem.address // 详细地址
            },
            userMap: this.$store.state.user,
            personList: familyList // 亲属信息
          }
          // params = JSON.stringify(params)
          data.form_params = params // 图片要件
          data.code = res.data.data
          updateOrder(data).then(res => {
            if (res.data.errcode === 0) {
              this.$router.push({
                name: 'workbench',
                params: {
                }
              })
            } else {
              this.$Notice.error({
                title: '订单信息修改失败',
                desc: res.data.errmsg
              })
              this.$router.push({
                name: 'workbench',
                params: {
                }
              })
            }
          })
        } else {
          this.$Notice.error({
            title: '信息查询失败',
            desc: res.data.errmsg
          })
          this.$router.push({
            name: 'workbench',
            params: {
            }
          })
        }
      })
    },
    getUserInfo () {
      let data = {
        method: 'selectUserType',
        card_no: this.formItem.person_card_no,
        // card_no: '211382199611083135',
        // type: '1'
        type: this.type,
        check: '1'
      }
      postCN(data).then(res => {
        if (res.data.errcode === 0) {
          this.formItem = {
            ...this.formItem,
            subsidy_type: res.data.data.user_type,
            subsidy_no: res.data.data.subsidy_no,
            address: res.data.data.address,
            start_in_time: res.data.data.start_in_time,
            tel: res.data.data.start_in_time,
            mobile: res.data.data.AZDF0011,
            settingList: res.data.data.settingList,
            area: res.data.data.area,
            street: res.data.data.street,
            community: res.data.data.community,
            area_code: res.data.data.area_code
          }
          this.baseInfo = {
            area: res.data.data.area,
            street: res.data.data.street,
            community: res.data.data.community,
            area_code: res.data.data.area_code
          }
          // console.log(res.data.data, 'res.data.dat')
          // console.log(this.formItem, '=======this.formItem=====')
        } else {
          this.$Notice.error({
            title: '订单创建失败',
            desc: res.data.errmsg
          })
          this.$router.go(-1)
        }
      })
    },
    goBack () {
      this.$router.push({
        name: 'workbench',
        params: {
        }
      })
    },
    updateInfo () {
      let formItem = {}
      let familyList = this.$refs.family.dataList
      if (this.formItem.cn_type === '1') { // 集中供暖
        // console.log(this.$refs.concentrated.formItem)
        formItem = this.$refs.concentrated.formItem
        formItem.params = this.$refs.concentratedAppendix.params
        let a_address = formItem.a_address
        let d_address = formItem.d_address
        d_address = d_address.replace(' ', '')
        if (a_address !== d_address) {
          let msg = '原始登记地址和填写地址不同，是否继续'
          if (!confirm(msg)) {
            return
          }
        }
        // if (!formItem.params.房产证) {
        //   this.$Notice.error({
        //     title: '房产证图片不能为空',
        //     desc: ''
        //   })
        //   return
        // }
        if (!formItem.work_address) {
          this.$Notice.error({
            title: '工作单位不能为空',
            desc: ''
          })
          return
        }
        if (formItem.subsidy_rmbone === 0) {
          this.$Notice.error({
            title: '采暖报销单价应大于0',
            desc: ''
          })
          return
        }
        // if (!formItem.fc_no) {
        //   this.$Notice.error({
        //     title: '房产证号不能为空',
        //     desc: ''
        //   })
        //   return
        // }
        if (!formItem.fc_m2) {
          this.$Notice.error({
            title: '房屋建筑面积不能为空',
            desc: ''
          })
          return
        }
      } else if (this.formItem.cn_type === '2') { // 分散供暖
        formItem = this.$refs.dispersion.formItem
        formItem.params = this.$refs.dispersionAppendix.params
        if (!formItem.work_address) {
          this.$Notice.error({
            title: '工作单位不能为空',
            desc: ''
          })
          return
        }
        if (!formItem.zf_type) {
          this.$Notice.error({
            title: '住房性质不能为空',
            desc: ''
          })
          return
        }
        if (!formItem.jz_type) {
          this.$Notice.error({
            title: '居住楼房/平房不能为空',
            desc: ''
          })
          return
        }
        if (!formItem.subsidy_mode) {
          this.$Notice.error({
            title: '补贴标准不能为空',
            desc: ''
          })
          return
        }
        // if (!formItem.params.常住人口证明) {
        //   this.$Notice.error({
        //     title: '常住人口证明图片不能为空',
        //     desc: ''
        //   })
        //   return
        // }
      } else if (this.formItem.cn_type === '3') { // 借住采暖
        // console.log(this.$refs.borrow.formItem)
        formItem = this.$refs.borrow.formItem
        let HeatingImgList = this.$refs.borrowAppendix.HeatingImgList
        formItem.params = this.$refs.borrowAppendix.params
        if (!formItem.fc_m2) {
          this.$Notice.error({
            title: '房屋建筑面积不能为空',
            desc: ''
          })
          return
        }
        if (formItem.subsidy_rmbone === 0) {
          this.$Notice.error({
            title: '采暖报销单价应大于0',
            desc: ''
          })
          return
        }
        // if (!formItem.fc_no) {
        //   this.$Notice.error({
        //     title: '房产证号不能为空',
        //     desc: ''
        //   })
        //   return
        // }
        // if (formItem.jz_mode === '租赁房屋') {
        // if (!formItem.params.房屋租赁合同) {
        //   this.$Notice.error({
        //     title: '房屋租赁合同图片不能为空',
        //     desc: ''
        //   })
        //   return
        // }
        // if (!formItem.params.租房未补贴证明) {
        //   this.$Notice.error({
        //     title: '租房未补贴证明图片不能为空',
        //     desc: ''
        //   })
        //   return
        // }
        // }
        let index = 0
        familyList.forEach(function (item) {
          if (item.is_subsidy === '0') {
            index = index + 1
          }
        })
        // console.log(HeatingImgList.length, 'length')
        if (HeatingImgList.length !== index) {
          let msg = '采暖不报销证明与家庭非保障成员数量不一致，是否提交'
          if (!confirm(msg)) {
            return
          }
        }
        // if (formItem.jz_mode === '借住房屋') {
        //   if (!formItem.params.房产证) {
        //     this.$Notice.error({
        //       title: '房产证图片不能为空',
        //       desc: ''
        //     })
        //     return
        //   }
        //   if (!formItem.params.采暖不报销证明 && index > 0) {
        //     this.$Notice.error({
        //       title: '采暖不报销证明图片不能为空',
        //       desc: ''
        //     })
        //     return
        //   }
        // }
      }
      if (!formItem.city || !formItem.street || !formItem.community) {
        this.$Notice.error({
          title: '家庭地址不能为空',
          desc: ''
        })
        return
      }
      if (!formItem.address) {
        this.$Notice.error({
          title: '详细地址不能为空',
          desc: ''
        })
        return
      }
      let data = {
        item_id: this.$route.params.itemid,
        cardno: this.$route.params.cardno,
        name: this.formItem.person_name,
        mobile: this.formItem.mobile
      }
      let subsidy_type = ''
      if (this.formItem.cn_type === '1' || this.formItem.cn_type === '3') {
        subsidy_type = '1'
      } else if (this.formItem.cn_type === '2') {
        subsidy_type = '2'
      }
      let area = {}
      let street = {}
      let community = {}
      if (formItem.city) {
        area = JSON.parse(formItem.city)
      }
      if (formItem.street) {
        street = JSON.parse(formItem.street)
      }
      if (formItem.community) {
        community = JSON.parse(formItem.community)
      }
      let params = {
        orderMap: {
          sex: this.formItem.person_sex,
          name: this.formItem.person_name,
          card_no: data.cardno, // 身份证号
          user_type: this.formItem.subsidy_type, // 救助类型
          single: this.formItem.single,
          type: this.type
        },
        infoMap: {
          fc_no: formItem.fc_no,
          work_address: formItem.work_address,
          area_code: community.area_code, // 行政区划码
          cn_type: this.formItem.cn_type, // 采暖方式1集中采暖2分散采暖3集中采暖（借住采暖）
          subsidy_type: subsidy_type, // 救助方式1 集中供暖 2 自行取暖
          params: formItem.params, // 要件
          fc_m2: formItem.fc_m2, // 房屋建筑面积
          subsidy_m2up: formItem.subsidy_m2up, // 补贴上限面积
          subsidy_rmb: formItem.subsidy_rmb, // 补贴金额
          persion_rmb: formItem.persion_rmb, // 个人承担金额
          subsidy_rmbone: formItem.subsidy_rmbone, // 采暖报销单价
          subsidy_mode: formItem.subsidy_mode, // 采暖补贴标准
          zf_type: formItem.zf_type, // 住房性质
          jz_type: formItem.jz_type, // 居住楼房平房
          jz_mode: formItem.jz_mode, // 居住方式
          area: area.name, // 所在区县
          street: street.name, // 所在街道
          community: community.name, // 所在社区
          remark: formItem.cn_rmb_all,
          address: formItem.d_address
        },
        homeMap: {
          person_name: this.formItem.person_name, // 户主姓名
          person_card_no: this.formItem.person_card_no, // 户主证件
          person_sex: this.formItem.person_sex, // 性别
          subsidy_type: this.formItem.subsidy_type, // 保障类型
          subsidy_no: this.formItem.subsidy_no, // 救助证号
          mobile: this.formItem.mobile, // 联系方式
          insert_type: '系统获取', // 添加方式 ：系统获取 、 手动添加
          insert_name: this.companyName, // 添加人
          address: this.formItem.address // 详细地址
        },
        userMap: this.$store.state.user,
        personList: familyList // 亲属信息
      }
      // params = JSON.stringify(params)
      data.form_params = params // 图片要件
      data.code = this.$route.params.code
      updateOrder(data).then(res => {
        if (res.data.errcode === 0) {
          this.$router.push({
            name: 'workbench',
            params: {
            }
          })
        } else {
          this.$Notice.error({
            title: '订单信息修改失败',
            desc: res.data.errmsg
          })
          this.$router.push({
            name: 'workbench',
            params: {
            }
          })
        }
      })
    },
    init () {
      // console.log('jinlaile 啦啦啦啦啦')
      let formItem = this.$refs.borrow.formItem
      this.formItem = {
        ...this.formItem,
        jz_mode: formItem.jz_mode
      }
      this.borrowAppendixType = false
      this.$nextTick(() => {
        this.borrowAppendixType = true
      })
    },
    familyLenght (index) {
      this.borrowAppendixType = false
      // console.log('调用familyLenght方法')
      this.formItem = {
        ...this.formItem,
        familyLenght: index
      }
      this.$nextTick(() => {
        this.borrowAppendixType = true
      })
    },
    updateCnType () {
      // console.log(this.formItem.cn_type, 'his.formItem.cn_type')
      // console.log(this.cn_type, 'his.cn_type')
      let that = this
      if (that.cn_type) {
        let formItem = {}
        if (that.formItem.cn_type !== '1' && that.cn_type === '1') {
          if (that.$refs.concentrated.formItem) {
            formItem = this.$refs.concentrated.formItem
            if (formItem.work_address || formItem.fc_no || formItem.fc_m2 || formItem.cn_rmb_all || formItem.subsidy_rmbone) {
              that.changeCnType()
            } else {
              that.cn_type = this.formItem.cn_type
              this.formItem = {
                ...this.formItem,
                work_address: '',
                fc_no: '',
                fc_m2: 0,
                city: '',
                area: this.baseInfo.area,
                street: this.baseInfo.street,
                community: this.baseInfo.community,
                subsidy_mode: '',
                params: null,
                subsidy_m2up: 0,
                subsidy_rmb: 0,
                persion_rmb: 0,
                subsidy_rmbone: 0,
                zf_type: '',
                jz_type: '',
                jz_mode: '借住房屋'
              }
            }
          }
        } else if (that.formItem.cn_type !== '2' && that.cn_type === '2') {
          if (this.$refs.dispersion.formItem) {
            formItem = this.$refs.dispersion.formItem
            if (formItem.work_address || formItem.zf_type || formItem.jz_type || formItem.cn_rmb_all || formItem.subsidy_mode) {
              that.changeCnType()
            } else {
              that.cn_type = this.formItem.cn_type
              this.formItem = {
                ...this.formItem,
                work_address: '',
                fc_no: '',
                fc_m2: 0,
                city: '',
                area: this.baseInfo.area,
                street: this.baseInfo.street,
                community: this.baseInfo.community,
                subsidy_mode: '',
                params: null,
                subsidy_m2up: 0,
                subsidy_rmb: 0,
                persion_rmb: 0,
                zf_type: '',
                jz_type: '',
                jz_mode: '借住房屋'
              }
            }
          }
        } else if (that.formItem.cn_type !== '3' && that.cn_type === '3') {
          if (this.$refs.borrow.formItem) {
            formItem = this.$refs.borrow.formItem
            if (formItem.fc_no || formItem.fc_m2 || formItem.cn_rmb_all || formItem.subsidy_rmbone) {
              that.changeCnType()
            } else {
              that.cn_type = this.formItem.cn_type
              this.formItem = {
                ...this.formItem,
                work_address: '',
                fc_no: '',
                fc_m2: 0,
                city: '',
                area: this.baseInfo.area,
                street: this.baseInfo.street,
                community: this.baseInfo.community,
                subsidy_mode: '',
                params: null,
                subsidy_m2up: 0,
                subsidy_rmb: 0,
                persion_rmb: 0,
                subsidy_rmbone: 0,
                zf_type: '',
                jz_type: '',
                jz_mode: '借住房屋'
              }
            }
          }
        }
      } else {
        this.cn_type = this.formItem.cn_type
      }
    },
    changeCnType () {
      let msg = '变更采暖方式会将数据清空，是否继续'
      if (confirm(msg)) {
        this.formItem = {
          ...this.formItem,
          work_address: '',
          fc_no: '',
          fc_m2: 0,
          city: '',
          area: this.baseInfo.area,
          street: this.baseInfo.street,
          community: this.baseInfo.community,
          subsidy_mode: '',
          params: null,
          subsidy_m2up: 0,
          subsidy_rmb: 0,
          persion_rmb: 0,
          subsidy_rmbone: 0,
          zf_type: '',
          jz_type: '',
          jz_mode: '借住房屋'
        }
        if (this.formItem.cn_type === '3') {
          this.formItem.subsidy_mode = '100'
          this.formItem.jz_mode = '借住房屋'
        }
      } else {
        // cnTypeState
        this.cnTypeState = false
        this.formItem.cn_type = this.cn_type
        this.$nextTick(() => {
          this.cnTypeState = true
        })
      }
      this.cn_type = this.formItem.cn_type
    }
  },
  mounted () {
    this.formItem.person_name = this.$route.params.name
    this.formItem.person_card_no = this.$route.params.cardno
    this.formItem.type = this.$route.params.type
    if (parseInt(this.formItem.person_card_no.substr(16, 1)) % 2 === 1) {
      this.formItem.person_sex = '男'
    } else {
      this.formItem.person_sex = '女'
    }
    if (this.$route.params.paramData) {
      this.formItem = {
        ...this.$route.params.paramData.homeMap,
        ...this.$route.params.paramData.orderMap,
        ...this.$route.params.paramData.infoMap,
        operation: this.$route.params.operation,
        subsidy_type: this.$route.params.paramData.orderMap.user_type,
        cn_rmb_all: this.$route.params.paramData.infoMap.remark
      }
      if (this.$route.params.paramData.infoMap.address) {
        this.formItem.d_address = this.$route.params.paramData.infoMap.address
      }
      if (this.$route.params.paramData.infoMap.subsidy_rmbone) {
        this.formItem.subsidy_rmbone = parseFloat(this.$route.params.paramData.infoMap.subsidy_rmbone)
      }
      this.familyList = this.$route.params.paramData.personList
      this.type = this.formItem.type
      this.cn_type = this.formItem.cn_type
    }
    this.getUserInfo()
    // else {
    //   this.getUserInfo()
    // }
  },
  computed: {
    companyName () {
      return this.$store.state.user.severUserInfo.name
    }
  }
}
</script>
<style></style>
